sysId = "";
tableName = "";
tableId = "";
nodeId = "";
nodeName = "";
$(function() {
    $("#tt")
        .tabs({
            onSelect: function(title, index) {
                var kpiTab = $("#tt").tabs('getSelected');
                if (kpiTab.attr('id') == "tabCommon") {
                    var url = "avicit/cbb/techclass/billdefine/billdefine_archive_common.jsp?sysId="+ sysId
                		+ "&tableId="
                		+ tableId
                		+ "&nodeId="
                		+ nodeId
                		+ "&tableName=" + tableName + "&nodeName=" + nodeName;
                    $("#iframe_tab_common").attr("src", url);
                } else if (kpiTab.attr('id') == "tabUnfiled") {
                	var url = "avicit/cbb/techclass/billdefine/billdefine_archive_unfiled.jsp?sysId="+ sysId
            		+ "&tableId="
            		+ tableId
            		+ "&nodeId="
            		+ nodeId
            		+ "&tableName=" + tableName + "&nodeName=" + nodeName;
                    $("#iframe_tab_unfiled").attr("src", url);
                } else if (kpiTab.attr('id') == "tabRecord") {
                	var url = "avicit/cbb/techclass/billdefine/billdefine_archive_record.jsp?sysId="+ sysId
            		+ "&tableId="
            		+ tableId
            		+ "&nodeId="
            		+ nodeId
            		+ "&tableName=" + tableName + "&nodeName=" + nodeName;
                    $("#iframe_tab_record").attr("src", url);
                } else if (kpiTab.attr('id') == "tabFiled") {
                	var url = "avicit/cbb/techclass/billdefine/billdefine_archive_filed.jsp?sysId="+ sysId
            		+ "&tableId="
            		+ tableId
            		+ "&nodeId="
            		+ nodeId
            		+ "&tableName=" + tableName + "&nodeName=" + nodeName;
                    $("#iframe_tab_filed").attr("src", url);
                }
            }
        });
});

//根据节点对应库表是否有数据，控制【表单设计】按钮权限
/*function buttonControl() {
	$.ajax({
		url : 'platform/cbb/billDefineManagerController/checkNodeHasData',
		data : {
			tableId : tableId
		},
		type : 'post',
		dataType : 'json',
		success : function(result) {
			var dataCount = result.dataCount;
			if (0 == dataCount) {
				$('#openForm').linkbutton('disable');
			} else {
				$('#openForm').linkbutton('enable');
			}
		}
	});
}*/

/**
 * 编辑数据
 */
/*var editIndex = undefined;

function endEditing() {
	if (editIndex == undefined) {
		return true;
	}
	if ($('#cbbBillDefineDataGrid').datagrid('validateRow', editIndex)) {
		$('#cbbBillDefineDataGrid').datagrid('endEdit', editIndex);
		editIndex = undefined;
		return true;
	} else {
		$.messager.show({
			title : '提示',
			// "请检查数据是否正确!"
			msg : commonLang.optip.content,
			timeout : 2000,
			showType : 'slide'
		});
		return false;
	}
}
*//**
 * 单击单元格
 * 
 * @param index
 *//*
function onClickRow(rowIndex, field, value) {
	if (editIndex != rowIndex) {
		if (endEditing()) {
			$('#cbbBillDefineDataGrid').datagrid('selectRow', rowIndex).datagrid('beginEdit', rowIndex);
			var srow = $('#cbbBillDefineDataGrid').datagrid('getRows');
			if (srow[rowIndex].id == "") {
				changeName(rowIndex);
			}
			editIndex = rowIndex;
		} else {
			$('#cbbBillDefineDataGrid').datagrid('selectRow', editIndex);
		}
	}
}
*//**
 * 提交改变的记录
 *//*
function accept() {
	if (endEditing()) {
		// 更新字段
		var rows = $("#cbbBillDefineDataGrid").datagrid('getChanges', 'updated');
		var updateData = JSON.stringify(rows);
		if (rows.length > 0) {
			$.ajax({
				url : 'platform/cbb/billDefineManagerController/updateCbbTabFormConfigData.json',
				data : {
					param : updateData,
					sysId : sysId,
					nodeId : nodeId,
					nodeName : nodeName,
					tableName : tableName,
					tableId : tableId
				},
				type : 'post',
				dataType : 'json',
				success : function(result) {
					if (result.flag == "success") {
						reloadDataGrid();
						$.messager.show({
							title : '提示',
							// '保存成功!'
							msg : commonLang.optip.save.success,
							timeout : 3000,
							showType : 'slide'
						});
					} else {
						if (result.flag == "failure") {
							$.messager.show({
								title : '提示',
								// "保存失败!"
								msg : commonLang.optip.save.fail,
								timeout : 2000,
								showType : 'slide'
							});
						} else {
							$.messager.alert('提示', result.flag, 'warning');
						}
					}
				}
			});
		}
	}
}
*//**
 * 重置
 *//*
function reset() {
	// '请确认', '确定要将所有数据重置吗？'
	$.messager.confirm(commonLang.tip.confirm, commonLang.optip.content2, function(b) {
		if (b) {
			// 更新字段
			var rows = $("#cbbBillDefineDataGrid").datagrid('getRows');
			var updateData = JSON.stringify(rows);
			if (rows.length > 0) {
				$.ajax({
					url : 'platform/cbb/billDefineManagerController/resetCbbTabFormConfigData.json',
					data : {
						param : updateData,
						sysId : sysId,
						nodeId : nodeId,
						nodeName : nodeName,
						tableName : tableName,
						tableId : tableId
					},
					type : 'post',
					dataType : 'json',
					success : function(result) {
						if (result.flag == "success") {
							reloadDataGrid();
							$.messager.show({
								title : '提示',
								// '重置成功!'
								msg : commonLang.optip.content3,
								timeout : 3000,
								showType : 'slide'
							});
						} else {
							if (result.flag == "failure") {
								$.messager.show({
									title : '提示',
									// "重置失败!"
									msg : commonLang.optip.content4,
									timeout : 2000,
									showType : 'slide'
								});
							} else {
								$.messager.alert('提示', result.flag, 'warning');
							}
						}
					}
				});
			}
		}
	});
}
*//**
 * 刷新表格数据
 *//*
function reloadDataGrid() {
	var url = 'platform/cbb/billDefineManagerController/getCbbBillDefineManagerData.json?sysId=' + sysId + '&nodeId=' + nodeId + '&tableName=' + tableName + "&tableId=" + tableId;
	$('#cbbBillDefineDataGrid').datagrid("options").url = url;
	$("#cbbBillDefineDataGrid").datagrid('load', {
		param : null
	});
}

*//**
 * 转换列类型
 * 
 * @param value
 * @param row
 * @param index
 * @returns
 *//*
function fomaterColType(value, row, index) {
	if (value == 'string') {
		return "字符串";
	} else if (value == 'integer') {
		return "整型";
	} else if (value == 'date') {
		return "日期时间型";
	}
	return value;
}

*//**
 * 转换是否
 * 
 * @param value
 * @param row
 * @param index
 * @returns
 *//*
function fomaterYn(value, row, index) {
	if (value == 'Y') {
		return "是";
	} else {
		return "否";
	}
	return value;
}

*//**
 * 跳转表单设计页面
 *//*
function openForm() {
	var dialogId = "formShowDialog";
	var toActionUrl = "platform/cbb/billDefineManagerController/toFormShow?dialogId=" + dialogId + "&sysId=" + sysId + "&nodeId=" + nodeId + "&tableName=" + tableName + "&nodeName=" + nodeName;
	// "表单设计"
	var usdAdd = new CommonDialog(dialogId, "1300", "1000", toActionUrl, commonLang.tip.formDesign, false, true, false);
	usdAdd.show();
}

*//**
 * 打开设置模板列数form
 *//*
function setColumn() {
	var dialogId = "formSetColumn";
	var toJspUrl = "avicit/cbb/techclass/billdefine/billdefine_set_column.jsp?nodeId=" + nodeId + "&tableId=" + tableId + "&dialogId=" + dialogId;
	// "设置模板列数"
	var usdAdd = new CommonDialog(dialogId, "800", "400", toJspUrl, commonLang.tip.setTempNum, false, true, false);
	usdAdd.show();
}*/